package com.zhuangjie.shop.controller;


import com.zhaungjie.base.conduit.R;
import com.zhuangjie.base.constant.ModuleSecurityNames;
import com.zhuangjie.security.annotations.PublicAPI;
import com.zhuangjie.shop.service.ShopCollectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 店铺收藏表 前端控制器
 * </p>
 *
 * @author zhuangjie
 * @since 2023-10-15
 */
@RestController
@RequestMapping("/shop-collect")
public class ShopCollectController {

    @Autowired
    private ShopCollectService shopCollectService;

    @ApiOperation("关注/取消关注店铺")
    @PostMapping("/followUnfollowShop/{shopId}/{follow}")
    @PublicAPI(modules = ModuleSecurityNames.USER)
    public R followUnfollowShop(@PathVariable("shopId") Long shopId, @PathVariable("follow") Boolean isFollow) {
        return R.capture(() -> shopCollectService.followUnfollowShop(shopId,isFollow));
    }

    @ApiOperation("查询用户是否关注店铺")
    @GetMapping("/{shopId}")
    @PublicAPI(modules = ModuleSecurityNames.USER)
    public R isFollow(@PathVariable("shopId") Long shopId) {
        return R.require(shopCollectService.isFollow(shopId));
    }

}

